package com.bcx.controller;

import com.bcx.pojo.Person;
import com.bcx.service.PersonService;
import com.bcx.tool.ResultEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;


@RestController
@CrossOrigin
@Api(tags = "处理Person请求")
public class PersonController {
    @Resource
    PersonService personService;
    @GetMapping("/selectAllPerson")
    @ApiOperation("查询所有person记录")
    public List<Person> selectAll(){
        List<Person>persons=personService.selectAll();
        return persons;
    }

    @GetMapping("/addperson")
    @ApiOperation("增加person")
    public ResultEntity<String> addPerson(Person person){
       Integer integer=personService.add(person);
       return ResultEntity.successWithoutData(integer+"");
    }
    @GetMapping("/delperson")
    public ResultEntity<String> delPerson(Integer id){
        Integer integer=personService.delete(id);
        return ResultEntity.successWithoutData(integer+"");
    }
}
